
package com.benimetum.beans;

import com.benimetum.items.Community;
import com.benimetum.items.Student;
import com.benimetum.items.Teacher;
import com.benimetum.managers.SearchManager;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

/**
 *
 * @author Ethem Cem Ozkan
 * @email ethemcem.ozkan@gmail.com
 * No 07110604
 */
@ManagedBean(name="SearchBean")
@SessionScoped
public class SearchBean 
{
    private Student[] studentResult;
    private Teacher[] teacherResult;
    private Community[] communityResult;
    private Student selected;
    private String text;
   

    public Community[] getCommunityResult() {
	  return communityResult;
    }

    public void setSelected(Student selected) {
        this.selected = selected;
    }

    public Student getSelected() {
        return selected;
    }

    public Student[] getStudentResult() {
	  return studentResult;
    }

    public String getText() {
	  return text;
    }
    
    public int getStudentResultLenght(){
        if(studentResult==null)
            return 0;
        return studentResult.length;
    }
    
    public int getTeacherResultLenght(){
        if(teacherResult==null)
            return 0;
        return teacherResult.length;
    }
    
    public int getCommunityResultLenght(){
        if(communityResult==null)
            return 0;
        return communityResult.length;
    }
    
    public Teacher[] getTeacherResult() {
	  return teacherResult;
    }

    public void setCommunityResult(Community[] communityResult) {
	  this.communityResult = communityResult;
    }

    public void setText(String text) {
	  this.text = text;
    }

    public void setStudentResult(Student[] studentResult) {
	  this.studentResult = studentResult;
    }

    public void setTeacherResult(Teacher[] teacherResult) {
	  this.teacherResult = teacherResult;
    }
    
    public void search(){
	  studentResult=SearchManager.searchStudent(text);
	  teacherResult=SearchManager.searchTeacher(text);
	  communityResult=SearchManager.searchCommunity(text);
    }
 
}
